/*
 * @Author: 王灿
 * @Date: 2019-10-27 15:07:03
 * @Description: file content
 */
/* eslint-disable */

import { Notification } from 'element-ui'

export const throwErr = (res) => {
  let message
  if (res.code === 4000) {
    message = '无效的token，请重新登入'

    Notification.error({
      title: '提示',
      message: message
    })
    
    // 跳转登录
    setTimeout(() => {
      window.location.href = '/'
    }, 1000)
  } else {
    message = res.msg || '网络请求发生错误'

    Notification.error({
      title: '提示',
      message: message || '网络请求发生错误'
    })
  }

  return Promise.reject(message || '网络请求发生错误')
}
